﻿/*
 * Copyright (c) Jason Paul Morley, 2010
 * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Core.EventMap eventMap = new Core.EventMap();
                Core.Database database = new Core.Database();
                Algorithms.Dijkstras dijk = new Algorithms.Dijkstras(eventMap, database);

                List<Core.Node> nodes = new List<Core.Node>();
                nodes.Add(new Core.Node(new Core.Point(60, 60)));
                nodes.Add(new Core.Node(new Core.Point(160, 60)));
                nodes.Add(new Core.Node(new Core.Point(60, 160)));
                nodes.Add(new Core.Node(new Core.Point(160, 160)));
                nodes.Add(new Core.Node(new Core.Point(260, 260)));
                nodes.Add(new Core.Node(new Core.Point(360, 160)));
                nodes.Add(new Core.Node(new Core.Point(160, 280)));
                nodes.Add(new Core.Node(new Core.Point(500, 60)));
                nodes.Add(new Core.Node(new Core.Point(500, 160)));
                nodes.Add(new Core.Node(new Core.Point(500, 260)));
                nodes.Add(new Core.Node(new Core.Point(400, 360)));
                nodes.Add(new Core.Node(new Core.Point(100, 400)));
                foreach (Core.Node n in nodes) database.Nodes.Add(n);

                List<Core.Edge> edges = new List<Core.Edge>();
                edges.Add(new Core.Edge(nodes[0], nodes[1], 2.0));
                edges.Add(new Core.Edge(nodes[0], nodes[2], 19.0));
                edges.Add(new Core.Edge(nodes[1], nodes[3], 12.0));
                edges.Add(new Core.Edge(nodes[2], nodes[3], 11.0));
                edges.Add(new Core.Edge(nodes[3], nodes[4], 5.0));
                edges.Add(new Core.Edge(nodes[3], nodes[5], 1.0));
                edges.Add(new Core.Edge(nodes[3], nodes[6], 7.0));
                edges.Add(new Core.Edge(nodes[1], nodes[7], 7.0));
                edges.Add(new Core.Edge(nodes[8], nodes[9], 12.0));
                edges.Add(new Core.Edge(nodes[4], nodes[9], 8.0));
                edges.Add(new Core.Edge(nodes[9], nodes[10], 25.0));
                edges.Add(new Core.Edge(nodes[4], nodes[10], 2.0));
                edges.Add(new Core.Edge(nodes[4], nodes[11], 13.0));
                foreach (Core.Edge e in edges) database.Edges.Add(e);

                dijk.UpdateDatabase();
                eventMap.Trigger(new Core.Event.GenerateSolution(nodes[0]));

                Console.Clear();
                foreach (Core.IStep n in database.Steps)
                    Console.WriteLine(n.Name());

                System.Windows.Forms.Application.Run(new Window(eventMap, database));
            }
            catch (Core.Error e)
            {
                Core.Debug.Log(e.Component, e.Function, e.Note);
            }
            catch (Exception e)
            {
                Core.Debug.Log("dotnetframework", "main()", e.Message);
            }
        }
    }
}
